package yunquan.wang.modules.base.entity;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import yunquan.wang.base.domain.IdEntity;

//码表类型

@Entity
@Table(name = "base_codetype")
public class CodeType extends IdEntity{
	/**
	 * 
	 */
	private static final long serialVersionUID = 3302072285582614068L;
	/**
	 * 码表名 customer_level
	 */
	@Column(name="type",length=30)
	@NotNull
	@Size(min=1, max=25)
	private String type;//code type like: customer level
	/**
	 * 国际化名称，如：code.sex(性别)
	 */
	@Column(name="name",length=50)
	@Size(min=1,max=20)
	private String name;//International Name;
	/**
	 * 码表值类型  String ,Integer ,data
	 */
	@Column(name="valuetype",length=20)
	@Size(min=1,max=20)
	private String valueType;// String Integer Date Long....
	
	@Column(name="editable",length=1)
	private Boolean editable; //是否可编辑
	
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "codeType")
	private Set<CodeValue>  codeValues=new HashSet<CodeValue>();
	/**
	 * 父类型
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "parent_id")
	private CodeType parent;
	
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "parent")
	private Set<CodeType>  children=new HashSet<CodeType>();
	
	public CodeType getParent() {
		return parent;
	}
	public void setParent(CodeType parent) {
		this.parent = parent;
	}
 
	public Set<CodeType> getChildren() {
		return children;
	}
	public void setChildren(Set<CodeType> children) {
		this.children = children;
	}
	public Boolean getEditable() {
		return editable;
	}
	public void setEditable(Boolean editable) {
		this.editable = editable;
	}
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
 
	public String getValueType() {
		return valueType;
	}
	public void setValueType(String valueType) {
		this.valueType = valueType;
	}
	public Set<CodeValue> getCodeValues() {
		return codeValues;
	}
	public void setCodeValues(Set<CodeValue> codeValues) {
		this.codeValues = codeValues;
	}
	 
	
	
}
